package com.ceshiren;

import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.chrome.ChromeDriver;

import java.time.Duration;

public class MainPage {
    private final By search_button = By.id("search-button");
    private final By term= By.id("search-term");
    private final ChromeDriver driver1 = new ChromeDriver();


    public MainPage start(){
        driver1.get("https://ceshiren.com/");

        //selenium3与4的用法不一样
        driver1.manage().timeouts().implicitlyWait(Duration.ofSeconds(10));
        return this;

    }


    public SearchPage search(String keyword) {

        driver1.findElement(search_button).click();
        driver1.findElement(term).sendKeys(keyword+ Keys.ENTER);
        return new SearchPage(driver1);

    }
}
